package br.composer.util;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public class FileOutput implements TestOutput {
	
	private PrintWriter pw;
	
	public FileOutput(String fileName){
		try {
			pw = new PrintWriter(new BufferedWriter(new FileWriter(fileName)));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public void addMsg(String msg) {
		pw.println(msg);
	}

	public void clearText() {
		//do nothing
	}
	
	public boolean save(){
		try{
			pw.flush();
			pw.close();
			return true;
		}catch(Exception e){
			return false;
		}
	}
	
	public static void main(String[] args) {
		FileOutput o = new FileOutput("tst.txt");
		o.addMsg("raphael");
		o.addMsg("augusto");
		o.save();
		
	}
}
